package com.zone.vehicle.superApps.view;

import android.app.Application;
import android.content.IntentFilter;

import com.tamsiree.rxkit.RxTool;
import com.zone.lib.download.db.DownloadDaoManager;
import com.zone.sdk_api.ApiManager;
import com.zone.sdk_api.common.Content;
import com.zone.vehicle.superApps.db.DaoManager;
import com.zone.vehicle.superApps.utils.SharedPreferencesUtil;
import com.zone.vehicle.superApps.view.receiver.SuperAppReceiver;

public class SuperApplication extends Application {

    private static SuperApplication application;

    public static SuperApplication getInstance(){
        return application;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        application = this;
        RxTool rxTool = RxTool.init(this)
                .debugLog(true)
                .debugLogFile(true)
                .crashLogFile(true);
        rxTool.crashProfile().enabled(true).logErrorOnRestart(false);
//        ApiManager.init("http://192.168.43.220:8080/");
        DaoManager.getInstance().init(this);
        DownloadDaoManager.getInstance().init(this);
//        ApiManager.init("http://192.168.43.220:8080/", true, this, "mock.json");
//        ApiManager.init("http://diagnose.dev.z-onesoftware.com/");
        ApiManager.init("http://diagnose.z-onesoftware.com/");//account QA
//        ApiManager.init("http://diagnose.dev.z-onesoftware.com/");//account dev
//        ApiManager.init("http://10.0.2.2/");
//        ApiManager.init("http://192.168.0.109:8080/");
//        ApiMock.init(this, "mock.json");
        SharedPreferencesUtil.getInstance(this).putSP(Content.VIN, "TSTBENCHSOA000004");
        SharedPreferencesUtil.getInstance(this).putSP(Content.USER_ID, "20");
        registerReceiver();
    }

    private void registerReceiver(){
        SuperAppReceiver receiver = new SuperAppReceiver();
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(SuperAppReceiver.INSTALL_JINGDONG_ACTION);
        intentFilter.addAction(SuperAppReceiver.TEST_REMOTE_ACTION);
        registerReceiver(receiver, intentFilter);
    }


}
